import static org.junit.Assert.*;

import org.junit.Test;


public class ShipTest {

	@Test
	/**
	 * Tests the default constructor of Ship
	 */
	public void shipDefaultConstructor() {
		
	}
	
	@Test
	/**
	 * Tests the getName function for the Ship that returns the ships name.
	 */
	public void getShipName() {
		Ship carrier = new AircraftCarrier();
		Ship bship = new Battleship();
		Ship cruiser = new Cruiser();
		Ship sub = new Submarine();
		Ship destroyer = new Destroyer();
		assertEquals("Return the name of the ship. Expected results: ", "Aircraft Carrier", carrier.getName());
		assertEquals("Return the name of the ship. Expected results: ", "Battleship", bship.getName());
		assertEquals("Return the name of the ship. Expected results: ", "Cruiser", cruiser.getName());
		assertEquals("Return the name of the ship. Expected results: ", "Submarine", sub.getName());
		assertEquals("Return the name of the ship. Expected results: ", "Destroyer", destroyer.getName());

	}
	
	@Test
	/**
	 * Test the getCells function to return all of the cells the ship occupies
	 */
	public void getAllShipCells() {
		Ship sub = new Submarine();
		sub.addCell("A1");
		sub.addCell("B1");
		sub.addCell("C1");
		assertEquals("Return the array of cells that the ship occupies. Expected results: ", "[A1, B1, C1]", sub.getCells().toString());
	}
	
	@Test
	/**
	 * Tests the getLength function to return the length of each type of Ship.
	 */
	public void getShipLength() {
		Ship carrier = new AircraftCarrier();
		Ship bship = new Battleship();
		Ship cruiser = new Cruiser();
		Ship sub = new Submarine();
		Ship destroyer = new Destroyer();
		assertEquals("Return the length of the ship. Expected results: ", 5, carrier.getLength());
		assertEquals("Return the length of the ship. Expected results: ", 4, bship.getLength());
		assertEquals("Return the length of the ship. Expected results: ", 3, cruiser.getLength());
		assertEquals("Return the length of the ship. Expected results: ", 3, sub.getLength());
		assertEquals("Return the length of the ship. Expected results: ", 2, destroyer.getLength());
	}

	@Test
	/**
	 * Test the hit method to increase the hitcount of a ship.
	 */
	public void increaseHitCount() {
		Ship carrier = new AircraftCarrier();
		carrier.hit();
		assertEquals("Increase the hit count of the ship. Expected results: ", 1, carrier.getHitCount());
	}
	
	@Test
	/**
	 * Test the isSunk function to return whether a sunken ship is sunk.
	 */
	public void shipIsSunk() {
		Ship sub = new Submarine();
		sub.hit();
		sub.hit();
		sub.hit();
		assertEquals("Return that the ship has been sunk. Expected results: ", "true", sub.isSunk().toString());
	}
	
	@Test
	/**
	 * Test the isSunk function to return if a ship that is still alive is sunken.
	 */
	public void shipIsNotSunk() {
		Ship sub = new Submarine();
		sub.hit();
		sub.hit();
		assertEquals("Return that the ship has not been sunk. Expected results: ", "false", sub.isSunk().toString());
	}

	@Test
	/**
	 * Test the addCells method to add a cell to a ships cell array.
	 */
	public void addCellsToShip() {
		Ship sub = new Submarine();
		sub.addCell("A1");
		sub.addCell("B1");
		sub.addCell("C1");
		assertEquals("Return the cells that have been added to the ships array. Expected results: ", "[A1, B1, C1]", sub.getCells().toString());
	}


}
